<html>
<head>
  <title>Register software for the station</title>
</head>

</style>

<body>
  <?php include("../header.php"); ?>

  <div>
    <form class="searchForm" action="./ComputerDetails_AddSoftware.php?action=search" method="get">
      Search an application to be added (you can use partial values, but at least first 3 letters).<br /><br />
      <input type="hidden" id="computer_id" name="computer_id" value="<?php echo $_GET['computer_id'] ?>">
      
      Title: <input type="text" id="title" name="title" style="width: 300px;"/><br />
      Producer: <input type="text" id="producer" name="producer" style="width: 300px;">
      <div style="float: right;">
        <input type="submit" value="Search"/>
      </div>
      <br /><br />
    </form>
    
    <table>
      <tr>
        <th>Title</th>
        <th>Producer</th>
        <th>Version</th>
        <th>Licence holder</th>
        <th>Serial number</th>
        <th>Licence start</th>
        <th>Licence expiration</th>
        <?php
          $id = $_GET['computer_id'];
  		    $con = get_connection();
  		    
          $title = "'".$_GET['title']."'";
          $producer = "'".$_GET['producer']."'";
          $query = "call SearchSoftware(".$title.", ".$producer.")";
  
          $result = mysql_query($query, $con) or die(mysql_error());
          
          while( $row = mysql_fetch_array($result) )
          {
            echo '<tr><td>' .$row[1]. '</td><td>' .$row[2]. '</td><td>' .$row[3]. '</td><td>' .$row[7]. '</td><td>' .$row[8] .
                 '</td><td>' .$row[9]. '</td><td>' .$row[10]. '</td><td><a href="./ComputerDetails.php?action=addSW&computer_id=' .$id. 
                 '&software_id=' .$row[0]. '">add to station</a></td></tr>';
          }
          
          mysql_close($con);
      ?>
    </table>
    <br />
    <div class="linkButton">
      <center><a <?php echo 'href="./ComputerDetails.php?computer_id=' .$id. '"'; ?> class="link">Cancel</a></center>
    </div>
    <br />
  </div>

</body>
</html>
